home *** CD-ROM | disk | FTP | other *** search
- ' Sample Source Code
- ' Michael Lininger, Lininger Technology, 1992
-
- DIM myDateTime.DateTimeRecSize: ' This is my DateTimeRec Variable
- ' We take an image of the FB DateTimeRec equate as our own
- ' Make it GLOBAL so our LOCAL FN's have access to it
- END GLOBALS
-
- CLEAR LOCAL
- LOCAL FN LTRIM$(work$)
-
- ' (c) Michael Lininger, Lininger Technology, 1992
- ' Last Modified: 5/21/92
-
- ' Remove_Leading_Spaces - Strips a string variable of Leading spaces (&H0D)
-
- ' Variable: work$ is passed to the Function (string$)
- ' Variable: work$ is returned by the Function (string$)
- ' Variable: Exit% is used as a non_space flag (integer)
-
- Exit% = _false
- DO
-
- LONG IF LEFT$(work$,1) = " "
- work$ = RIGHT$(work$,LEN(work$)-1)
- XELSE
- Exit% = _true
- END IF
-
- UNTIL Exit% OR LEN(work$) < 1
-
- END FN = work$
-
-
- CLEAR LOCAL
- LOCAL FN PadZero$(work$)
-
- ' (c) Michael Lininger, Lininger Technology, 1992
- ' Last Modified: 5/21/92
-
- ' Pad_Leading_Zero - Adds leading 0 (Zero) for date format
-
- ' Variable: work$ is passed to the Function (string$)
- ' Variable: work$ is returned by the Function (string$)
-
- IF LEN(work$) = 1 THEN work$ = "0" + work$
-
- END FN = work$
-
-
- CLEAR LOCAL
- LOCAL FN FindDay$
-
- ' (c) Michael Lininger, Lininger Technology, 1992
- ' Last Modified: 10/14/92
-
- ' Converts the numeric GLOBAL record.variable myDateTime.DayofWeek
- ' into a descriptive string$ variable.
-
- ' Variable: myDateTime.DayofWeek part of the FB .DateTimeRec Equate
- ' Variable: Dy$ holding variable for DayofWeek string$ description
-
- SELECT myDateTime.DayofWeek
- CASE 1:Dy$="Sun"
- CASE 2:Dy$="Mon"
- CASE 3:Dy$="Tue"
- CASE 4:Dy$="Wed"
- CASE 5:Dy$="Thu"
- CASE 6:Dy$="Fri"
- CASE 7:Dy$="Sat"
- CASE ELSE:Dy$="???": ' Martian Day
- END SELECT
-
- END FN = Dy$
-
- CLEAR LOCAL
- LOCAL FN FindMonth$
-
- ' (c) Michael Lininger, Lininger Technology, 1992
- ' Last Modified: 10/14/92
-
- ' Converts the numeric GLOBAL record.variable myDateTime.Month
- ' into a descriptive string$ variable.
-
- ' Variable: myDateTime.Month part of the FB .DateTimeRec Equate
- ' Variable: Mn$ holding variable for Month string$ description
-
- SELECT myDateTime.Month
- CASE 1:Mn$ = "Jan"
- CASE 2:Mn$ = "Feb"
- CASE 3:Mn$ = "Mar"
- CASE 4:Mn$ = "Apr"
- CASE 5:Mn$ = "May"
- CASE 6:Mn$ = "Jun"
- CASE 7:Mn$ = "Jul"
- CASE 8:Mn$ = "Aug"
- CASE 9:Mn$ = "Sep"
- CASE 10:Mn$ = "Oct"
- CASE 11:Mn$ = "Nov"
- CASE 12:Mn$ = "Dec"
- CASE ELSE: Mn$= "???": ' Martian Month?
- END SELECT
-
- END FN = Mn$
-
-
- CLEAR LOCAL
- LOCAL FN DateToString$
-
- ' (c) Michael Lininger, Lininger Technology, 1992
- ' Last Modified: 10/14/92
-
- ' Date_to_String - Converts DateTimeRec into a formatted date_time string$
-
- ' Variable: myDateTime.DateTimeRec GLOBAL
- ' Variable: work$ is returned by the Function (string$)
- ' Variable: amPM$ is work variable for AM or PM indicator
-
- ' determine if it is AM (day) or PM (night) - Lets not use Military Time
- SELECT myDateTime.Hour
- CASE 0
- myDateTime.Hour = 12
- amPM$ = "AM"
- CASE < 12
- amPM$ = "AM"
- CASE 12
- amPM$ = "PM"
- CASE ELSE
- amPM$ = "PM"
- myDateTime.Hour = myDateTime.Hour - 12
- END SELECT
-
- work$ = STR$(myDateTime.Year): Year$ = FN LTRIM$(work$)
- work$ = STR$(myDateTime.Month): work$ = FN LTRIM$(work$):MonthNum$ = FN PadZero$(work$)
- work$ = STR$(myDateTime.Day): work$ = FN LTRIM$(work$):Day$ = FN PadZero$(work$)
- work$ = STR$(myDateTime.Hour): work$ = FN LTRIM$(work$):Hour$ = FN PadZero$(work$)
- work$ = STR$(myDateTime.Minute):work$ = FN LTRIM$(work$):Minute$ = FN PadZero$(work$)
- work$ = STR$(myDateTime.Second):work$ = FN LTRIM$(work$):Second$ = FN PadZero$(work$)
- MonthName$ = FN FindMonth$
- DayofWeek$ = FN FindDay$
- work$ = DayofWeek$+", " + MonthName$+" "+Day$+", "+Year$ +" "+Hour$+":"+Minute$+":"+Second$+" "+amPM$
- ' Other Style Format
- ' work$ = MonthNum$+"/"+Day$+"/"+Year$+" "+Hour$+":"+Minute$+":"+Second$
- END FN = work$
-
-
- WINDOW OFF: 'Close Default Window
- WINDOW #1: 'Open our own default window
- TEXT 0,12,0,0: 'System Font
-
- PRINT
- PRINT " This is a sample Seconds to Date and"
- PRINT " Date to Seconds. (ML 10/92)"
- PRINT
-
- ' Convert Seconds to a full string$ Date/Time
- Address% = VAL("&H20C"): ' Memory Address for Seconds since 1904
- Today& = PEEK LONG(Address%): ' Get Todays Date/Time is Seconds since 1904
- CALL SECS2DATE(Today&,VARPTR(myDateTime)) ' Convert Seconds to Date Numerials
- work$ = FN DateToString$: ' Format myDateTime.DateTimeRec into a string$
- PRINT " Today is: ";TAB(20);work$: ' Print it to Screen
-
- ' Convert a string Date/Time into Seconds
- ' This is useful for compacting date/time variables into
- ' a single 4_Byte variable.
-
- workDate$ = "05/20/1992"
- workTime$ = "00:34:48"
- myDateTime.Year = VAL(RIGHT$(workDate$,4))
- myDateTime.Month = VAL(LEFT$(workDate$,2))
- myDateTime.Day = VAL(MID$(workDate$,4,2))
- myDateTime.Hour = VAL(LEFT$(workTime$,2))
- myDateTime.Minute = VAL(MID$(workTime$,4,2))
- myDateTime.Second = VAL(RIGHT$(workTime$,2))
- myDateTime.DayofWeek = 0: ' FN DATE2SECS will figure it for you
-
- dateSeconds& = FN DATE2SECS(VARPTR(myDateTime)) ' Convert Date Numerials into Seconds
-
- PRINT ""
- PRINT " Some past date in seconds..."
- PRINT ""
- PRINT " Seconds: ";TAB(20);dateSeconds&: ' Print Signed Seconds to screen
-
- ' Now lets check to make sure our dateSeconds& (4_Byte) variable
- ' converts back into the proper date. Plus an added bonus, it
- ' will tell us the day of the week that date was on.
-
- CALL SECS2DATE(dateSeconds&,VARPTR(myDateTime)): ' Convert Seconds to Date Numerials
- work$ = FN DateToString$: ' Format myDateTime.DateTimeRec into a string$
- PRINT " Past Date: ";TAB(20);work$: ' Print it to screen
- PRINT
- PRINT "Press Mouse Key to Quit..."
-
- ' Wait till Mouse Button is pressed
- DO
- UNTIL FN BUTTON
- WINDOW CLOSE #1
- END
-